package com.gt.web.controller.app;

import com.gt.app.domain.EsLifeCases;
import com.gt.app.domain.EsUserBaseInfo;
import com.gt.app.domain.dto.EsLifeCasesDto;
import com.gt.app.service.EsLifeCasesService;
import com.gt.app.service.EsUserBaseInfoService;
import com.gt.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 用户信息接口 前端控制器
 * </p>
 *
 * @author caidesheng
 */
@Slf4j
@RestController
@RequestMapping("userInfo")
@Api(tags = "用户基本信息接口")
public class EsUserInfoController {

    @Autowired
    private EsUserBaseInfoService esUserBaseInfoService;
    @Autowired
    private EsLifeCasesService esLifeCasesService;

    @ApiOperation(value = "新增个人基本信息")
    @PostMapping(value = "addUserBaseInfo")
    public AjaxResult addUserBaseInfo(@RequestBody EsUserBaseInfo esUserBaseInfo) {
        esUserBaseInfoService.add(esUserBaseInfo);
        return AjaxResult.success();
    }

    @ApiOperation(value = "获取个人基本信息")
    @GetMapping(value = "getUserBaseInfo")
    public AjaxResult getUserBaseInfo() {
        EsUserBaseInfo esUserBaseInfo = esUserBaseInfoService.getUserBaseInfo();
        return AjaxResult.success(esUserBaseInfo);
    }

    @ApiOperation(value = "新增生活状况")
    @PostMapping(value = "addLifeCases")
    public AjaxResult addLifeCases(@RequestBody EsLifeCasesDto esLifeCasesDto) {
        esLifeCasesService.addLifeCases(esLifeCasesDto);
        return AjaxResult.success();
    }


    @ApiOperation(value = "获取生活状况")
    @GetMapping(value = "getLifeCases")
    public AjaxResult getLifeCases() {
        EsLifeCasesDto lifeCases = esLifeCasesService.getLifeCases();
        return AjaxResult.success(lifeCases);
    }
}
